<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="day12.Address"%>
<%@page import="day12.Person"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri ="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>el表达式获取数据事例</title>
</head>
<body>
	<%
		request.setAttribute("username", "aaa");
	%>

	${username }
	<!--相当于pageContext.findAttribute("name")  -->
	<hr>
	<!-- 获取bean属性 -->
	<%
		Person p = new Person();
		p.setAge(12);
		request.setAttribute("person", p);
	%>
	${person.age }
	<hr>

	<!-- 在jsp中，使用el表达式，可以获取bean中的xx属性 -->
	<%
		Person person = new Person();
		Address a = new Address();
		person.setAddress(a);
		request.setAttribute("person", person);
	%>
	
	${person.address.name }
	<hr>
	<%
	Person p1=new Person();
	p1.setName("xiayq");
	Person p2=new Person();
	p2.setName("luwz");
	List list=new ArrayList();
	list.add(p1);
	list.add(p2);
	request.setAttribute("list", list);
	
	%>
	
	${list[1].name }
	<!--迭代集合  -->
	<c:forEach var="person" items="${list }">
	${person.name}
	</c:forEach>
	<hr>
	<% 
	Map map=new HashMap();
	map.put("a", "aaaaaa");
	map.put("1", "bbbbb");
	request.setAttribute("map", map);
	%>
	<c:forEach var="me" items="${map }">
	${me.key }=${me.value }
	
	</c:forEach>
	${map.a }
	<%-- ${map.1 } 错误 --%>
	${map["1"] }
	
	
</body>
</html>